<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增鉴定样本')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-identsample-add">


        <!--            <button onclick="reloadtions()">刷新</button>-->

        <input class="form-control" name="registerId" type="hidden" th:value="*{registerId}">


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">样本名称：</label>
                    <div class="col-sm-8">
                        <input name="sampleName" class="form-control" type="text" required>
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">样本数量：</label>
                    <div class="col-sm-8">
                        <input name="sampleNumber" class="form-control digits" type="number" number required>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">系来函所附清单的序号：</label>
                    <div class="col-sm-8">
                        <input name="letterOrder" class="form-control" type="text" required>
                    </div>
                </div>
            </div>


        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">封面：</label>
                    <div class="col-sm-10">
                        <input class="hidden" name="frontCover">
                        <div class="file-loading">
                            <input class="form-control file-upload" multiple id="frontCover" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-10">
                        <button type="button" class="btn btn-w-m btn-warning" onclick="photograph('frontCover')">
                            <i class="fa fa-check"></i>拍照
                        </button>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">封底：</label>
                    <div class="col-sm-10">
                        <input type="hidden" name="backCover">
                        <div class="file-loading">
                            <input class="form-control file-upload" multiple id="backCover" name="file" type="file">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-10">
                        <button type="button" class="btn btn-w-m btn-warning" onclick="photograph('backCover')">
                            <i class="fa fa-check"></i>拍照
                        </button>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">版权信息：</label>
                    <div class="col-sm-10">
                        <input name="publishInfo" type="hidden">
                        <div class="file-loading">
                            <input class="form-control file-upload-word" multiple id="publishInfo" name="file"
                                   type="file" accept="image/.jpg,.png,.bmp,.jpeg,.jpg">
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button type="button" class="btn btn-w-m btn-warning" onclick="photograph('publishInfo')">
                                <i class="fa fa-check"></i>拍照
                            </button>
                            <button type="button" class="btn btn-w-m btn-warning" onclick="getocr()">
                                <i class="fa fa-check"></i>识别
                            </button>
                        </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">识别信息：</label>
                    <div class="col-sm-10">
                        <textarea name="publishInfoText" style="height: 300px" id="publishInfoText"
                                  class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">其他：</label>
                    <div class="col-sm-10">
                        <textarea name="other" maxlength="500" rows="3"
                                  class="form-control">[[*{explanation}]]</textarea>
                    </div>
                </div>
            </div>
        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">样本类别：</label>
                    <div class="col-sm-8">
                        <select id="sampleType" name="sampleType" class="form-control" >

                        </select>
                    </div>
                </div>
            </div>
        </div>


        <div id="ChangeContent"></div>


        <div class="row" style="padding-top: 30px">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i
                        class="fa fa-check"></i>确 定
                </button>&nbsp;
                <button type="button" class="btn btn-sm btn-primary" onclick="nextSubmit()">
                    <i class="fa fa-check"></i>下一个
                </button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                        class="fa fa-reply-all"></i>关 闭
                </button>
            </div>
        </div>
    </form>
</div>

<div class="hidden">
    <!--图书-->
    <div id="book">
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">作者：</label>
                    <div class="col-sm-8">
                        <input name="author" class="form-control" type="text">

                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">印刷单位：</label>
                    <div class="col-sm-8">
                        <input name="printingUnit" class="form-control" type="text">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">国际标准书号：</label>
                    <div class="col-sm-8">
                        <input name="interBookNumber" class="form-control" type="text" maxlength="60">

                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">经销：</label>
                    <div class="col-sm-8">
                        <input name="distribution" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">CIP数据核字号：</label>
                    <div class="col-sm-8">
                        <input name="cipNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">版次：</label>
                    <div class="col-sm-8">
                        <input name="edition" class="form-control" type="text" maxlength="60" number>
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出版单位：</label>
                    <div class="col-sm-8">
                        <input name="publishingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">印次：</label>
                    <div class="col-sm-8">
                        <input name="printTimes" class="form-control" type="text" maxlength="60" number>
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">发行单位：</label>
                    <div class="col-sm-8">
                        <input name="issueUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">开本：</label>
                    <div class="col-sm-8">
                        <input name="format" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">印张：</label>
                    <div class="col-sm-8">
                        <input name="printedSheet" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">字数：</label>
                    <div class="col-sm-8">
                        <input name="wordCount" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">印数：</label>
                    <div class="col-sm-8">
                        <input name="printedNumber" class="form-control" type="text" maxlength="60" number>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">定价：</label>
                    <div class="col-sm-8">
                        <input name="pricing" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>
    </div>
    <!--期刊-->

    <div id="periodical">
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">期号：</label>
                    <div class="col-sm-8">
                        <input name="issue" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">主管单位：</label>
                    <div class="col-sm-8">
                        <input name="competentUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">主办单位：</label>
                    <div class="col-sm-8">
                        <input name="organizers" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出版单位：</label>
                    <div class="col-sm-8">
                        <input name="publishingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">印刷单位：</label>
                    <div class="col-sm-8">
                        <input name="printingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">发行单位：</label>
                    <div class="col-sm-8">
                        <input name="issueUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">出版时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="publishingTime" class="form-control" placeholder="yyyy-MM-dd" type="text"  autocomplete="off">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>

            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">国内统一连续出版物号：</label>
                    <div class="col-sm-8">
                        <input name="nationUnifiedPubliNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">广告经营许可证：</label>
                    <div class="col-sm-8">
                        <input name="adverBusinessLicense" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">定价：</label>
                    <div class="col-sm-8">
                        <input name="pricing" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!--报纸-->

    <div id="newspaper">
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">期号：</label>
                    <div class="col-sm-8">
                        <input name="issue" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">版数：</label>
                    <div class="col-sm-8">
                        <input name="by2" class="form-control" type="text" maxlength="60" number>
                    </div>
                </div>

            </div>
        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">主管单位：</label>
                    <div class="col-sm-8">
                        <input name="competentUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">主办单位：</label>
                    <div class="col-sm-8">
                        <input name="organizers" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出版单位：</label>
                    <div class="col-sm-8">
                        <input name="publishingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">印刷单位：</label>
                    <div class="col-sm-8">
                        <input name="printingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>

        </div>


        <div class="row">
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">出版时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="publishingTime" class="form-control" placeholder="yyyy-MM-dd" type="text"  autocomplete="off">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>

            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">国内统一连续出版物号：</label>
                    <div class="col-sm-8">
                        <input name="nationUnifiedPubliNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">广告经营许可证：</label>
                    <div class="col-sm-8">
                        <input name="adverBusinessLicense" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">定价：</label>
                    <div class="col-sm-8">
                        <input name="pricing" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>
    </div>

    <!--音像制品-->

    <div id="music">
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出版单位：</label>
                    <div class="col-sm-8">
                        <input name="publishingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">版号：</label>
                    <div class="col-sm-8">
                        <input name="versionNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">出版时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="publishingTime" class="form-control" placeholder="yyyy-MM-dd" type="text"  autocomplete="off">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">ifpi：</label>
                    <div class="col-sm-8">
                        <input name="ifpi" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>


        <div class="row">


            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">定价：</label>
                    <div class="col-sm-8">
                        <input name="pricing" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>


    </div>

    <!--网络出版物-->

    <div id="online">
        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">版本号：</label>
                    <div class="col-sm-8">
                        <input name="versionNumberNet" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">出版单位：</label>
                    <div class="col-sm-8">
                        <input name="publishingUnit" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>


        <div class="row">

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">网络出版物号：</label>
                    <div class="col-sm-8">
                        <input name="onlinePubliNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">网络出版服务许可证：</label>
                    <div class="col-sm-8">
                        <input name="onlineServiceNumber" class="form-control" type="text" maxlength="60">
                    </div>
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">网址：</label>
                    <div class="col-sm-8">
                        <input name="url" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">审批文号：</label>
                    <div class="col-sm-8">
                        <input name="approvalNumber" class="form-control" type="text">
                    </div>
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">原出版单位：</label>
                    <div class="col-sm-8">
                        <input name="originalPublisher" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">

                <div class="form-group">
                    <label class="col-sm-4 control-label">书号：</label>
                    <div class="col-sm-8">
                        <input name="bookNumber" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">刊号：</label>
                    <div class="col-sm-8">
                        <input name="issueNumber" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
        </div>
    </div>

    <!--其他-->

    <div id="other">
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">相关信息：</label>
                    <div class="col-sm-10">
                        <textarea name="relatedInfo" maxlength="500" rows="3"
                                  class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<!--    <script src="js/jquery.form.js"></script>-->
<script th:src="@{/js/jquery.form.js}"></script>
<!--模板JS引入-->
<script th:src="@{/ajax/libs/template/template.js}"></script>
<!--拍照预览图片模板-->
<script type="text/html" id="template">
    <div class="file-preview-frame krajee-default  kv-preview-thumb file-preview-success"
         id={{id}} data-fileindex="0" data-fileid={{title}} data-template="image">
        <div class="kv-file-content">
            <img src={{src}} class="file-preview-image kv-preview-data" title={{title}}
                 style="width:213px;height:160px;" alt={{title}}>
        </div>
        <div class="file-thumbnail-footer">
            <div class="file-footer-caption" title={{title}}>
                <div class="file-caption-info">{{title}}</div>
                <div class="file-size-info"><samp>(108.21 KB)</samp></div>
            </div>
            <div class="file-thumb-progress kv-hidden" style="display: block;">
                <div class="progress">
                    <div class="progress-bar bg-success progress-bar-success" role="progressbar" aria-valuenow="100"
                         aria-valuemin="0" aria-valuemax="100" style="width:100%;">
                        完成
                    </div>
                </div>
            </div>
            <div class="file-upload-indicator" title="上传"><i class="glyphicon glyphicon-ok-sign text-success"></i></div>
            <div class="file-actions">
                <div class="file-footer-buttons">
                    <button type="button" class="kv-file-upload btn btn-sm btn-kv btn-default btn-outline-secondary"
                            title="上传文件" style="display: none;"><i class="glyphicon glyphicon-upload"></i></button>
                    <button type="button" class="kv-file-remove btn btn-sm btn-kv btn-default btn-outline-secondary"
                            title="删除文件"><i class="glyphicon glyphicon-trash"></i></button>
                    <button type="button" class="kv-file-down btn btn-sm btn-default" title="下载附件"><i
                            class="fa fa-cloud-download"></i></button>
                </div>
            </div>

            <div class="clearfix"></div>
        </div>
    </div>
</script>

<script th:inline="javascript">
    var prefix = ctx + "publish/identsample"
    $("#form-identsample-add").validate({
        focusCleanup: true
    });

    /*时间控件*/
    $("input[name='printedTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
    $("input[name='publishingTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
    $("input[name='issueTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    /*上传参数配置 name 属性值必须为file*/
    var fileConfig = {
        uploadUrl: '/common/upload',
        maxFileSize: 30000,
        browseClass: 'btn btn-primary',
        dropZoneTitle: "拖拽文件到这里",
    }
    /*循环加载页面上传组件*/
    $.each($(".file-upload"), function () {
        var nodeId = $(this).attr('id');
        $.common.uploadFileInput(fileConfig, $(this), "input[name='" + nodeId + "']");
    });

    /*高拍仪调用*/
    function photograph(parameter) {
        $.modal.open("拍照", ctx + "publish/identsample/indexOne?parameter=" + parameter, 1200);
    }
    /*高拍仪回调*/
    function photo(_base64, _parameter, arr) {
        console.log(arr);
        $.operate.post('/common/uploadBase64',
            {"base64": _base64},
            function (result) {
                if (result.code == web_status.SUCCESS) {
                    if ($("input[name='" + _parameter + "']").val() == null || $("input[name='" + _parameter + "']").val() == "") {
                        $("input[name='" + _parameter + "']").val(result.fileName);
                    } else {
                        $("input[name='" + _parameter + "']").val($("input[name='" + _parameter + "']").val() + ',' + result.fileName);
                    }
                    var id = new Date().getTime();
                    var title = result.fileName.substring(result.fileName.lastIndexOf("/") + 1);
                    var data = {
                        src: result.fileName,
                        arr: '0',
                        title: title,
                        id: id,
                    };

                    // 将数据放入模板中
                    var res = template("template", data);
                    $("input[name='" + _parameter + "']").next().find(".file-drop-zone-title").remove();
                    // 将模板放入页面中
                    $("input[name='" + _parameter + "']").next().find(".file-preview-thumbnails").append(res);
                    $("#" + _parameter).fileinput('_initFileActions');
                } else {
                    $.modal.alertError(result.msg);
                }
            }
        );

    }

    /*重新加载上传组件*/
    function reloadFileInput(_parameter) {
        var fileConfig = {
            uploadUrl: '/common/upload',
            maxFileSize: 30000,
            browseClass: 'btn btn-primary',
            dropZoneTitle: "拖拽文件到这里",
        }
        $.common.uploadFileInput(fileConfig, ("#" + _parameter), 'input[name="' + _parameter + '"]');
    }

    $(document).ready(function () {
        //图片识别
        $("#publishInfo").fileinput({
            // uploadUrl: '/common/upload',
            uploadUrl: '/publish/sample/picUpload',
            maxFileCount: 0,
            showUpload: false,
            showRemove: false,
            maxFileSize: 30000,
            autoReplace: true,
            allowedFileExtensions: ['jpg', 'png', 'bmp', 'jpeg'],
            showUpload: false, //是否显示上传按钮
            showCaption: true,//是否显示标题
            browseClass: "btn btn-primary",//按钮样式
            layoutTemplates: {
                //actionDelete:'', //去除上传预览的缩略图中的删除图标
                actionUpload: '',//去除上传预览缩略图中的上传图片图标；
                //actionZoom:''   //去除上传预览缩略图中的查看详情预览的缩略图标。
            },
        }).on('filebatchselected', function (event, data, id, index) {
            $(this).fileinput("upload");
        }).on('fileuploaded', function (event, data, previewId, index) {
            // data.response.url   data.response.fileName
            if (data.response && data.response.code && data.response.code == '500') {
                $.modal.alertError("请上传正确格式的图片");
            } else {
                // $("#infoText").val(data.response.result);
                // $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName);
                $("#infoText").val(data.response.result);
                if ($("input[name='" + event.currentTarget.id + "']").val() == "") {
                    $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName);
                } else {
                    $("input[name='" + event.currentTarget.id + "']").val($("input[name='" + event.currentTarget.id + "']").val() + ',' + data.response.fileName);
                }
            }
        }).on('fileremoved', function (event, id, index) {
        }).on('filesuccessremove', function (event, id, index) {//删除新上传的文件
            var nu = -1;
            var src = $("#" + id).attr("title");
            var fileUrlList = $("input[name='" + event.currentTarget.id + "']").val().split(",");
            if (src == "" || src == null) {
                src = $("#" + id + " img").attr("title");
                for (var i = 0; i <= fileUrlList.length - 1; i++) {
                    var src1 = fileUrlList[i].substring(fileUrlList[i].lastIndexOf("/") + 1);
                    if (src1 == src) {
                        nu = i;
                    }
                }
            } else {
                for (var i = 0; i <= fileUrlList.length - 1; i++) {
                    var title1 = fileUrlList[i].substring(fileUrlList[i].lastIndexOf("/") + 1);
                    if (title1 == src) {
                        nu = i;
                    }
                }
            }
            fileUrlList.splice(nu, 1);
            $("input[name='" + event.currentTarget.id + "']").val(fileUrlList);
        }).on('filedeleted', function (event, id, index) {
            debugger
            $("input[name='" + event.currentTarget.id + "']").val('')
        });

        $("#sampleType").change(function () {
            var selected = $(this).children('option:selected').val();
            getChangeContent(selected);
        });

        findInfoByRegisterId();

    });

    /*根据registerId查询样本类别*/
    function findInfoByRegisterId() {
        var _registerId = $("input[name=registerId]").val();
        $.ajax({
            type: 'post',
            url: ctx + "publish/register/findById/" + _registerId,
            dataType: "json",
            async: true, //是否异步请求
            success: function (datas) {
                var _category = datas.category.split(",");
                var str;
                for (var i = 0; i < _category.length; i++) {
                    str += "<option value='" + _category[i] + "'>" + _category[i] + "</option>";
                }
                getChangeContent(_category[0]);
                $("#sampleType").append(str);
            }
        });
    }

    function getChangeContent(sampleType) {
        var samepleId = 'book'
        if (sampleType == "图书") {
            samepleId = 'book';
        } else if (sampleType == "期刊") {
            samepleId = 'periodical';
        } else if (sampleType == "报纸") {
            samepleId = 'newspaper';
        } else if (sampleType == "音像制品") {
            samepleId = 'music';
        } else if (sampleType == "电子出版物") {
            samepleId = 'music';
        } else if (sampleType == "网络出版物") {
            samepleId = 'online';
        } else if (sampleType == "其他") {
            samepleId = 'other';
        }
        var htmls = $(eval(samepleId)).html()
        $("#ChangeContent").empty();
        $("#ChangeContent").append(htmls)
        $("input[name='publishingTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.saveTab(prefix + "/add", $('#form-identsample-add').serialize());
        }
    }

    // 文字识别获得 图片里的字
    function getocr() {
        // picPathsUpload   publishInfo
        var paths = $("input[name='publishInfo']").val();
        if ($.common.isEmpty(paths)) {
            $.modal.alertWarning("没有出版信息");
            return;
        }
        $.operate.post('/publish/sample/picPathsUpload',
            {"paths": paths},
            function (result) {
                console.log(result);
                if (result.code == web_status.SUCCESS) {
                    $('#publishInfoText').val(result.result);
                } else {
                    $.modal.alertError(result.msg);
                }
            }
        );
    }

    function reloadtions() {
        location.reload();
    }


    function nextSubmit() {
        if ($.validate.form()) {
            var url = prefix + "/add";
            var data = $('#form-identsample-add').serialize();
            var config = {
                url: url,
                type: "post",
                dataType: "json",
                data: data,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                    $.modal.disable();
                },
                success: function (result) {
                    if (typeof callback == "function") {
                        callback(result);
                    }
                    $.operate.ajaxSuccess(result);
                }
            };
            $.ajax(config)
            var sampleType = $("select[name='sampleType'] option:selected").text();
            $('#form-identsample-add').resetForm();
            $("input[name='frontCover']").val('');
            $("input[name='backCover']").val('');
            $("input[name='publishInfo']").val('');
            $("#sampleType").val(sampleType);
        }
    }



    /**
     * 其他按钮（如下载）绑定时间
     */
    $(document).on('click', '.kv-file-down', function (e, id, index) {
        var download = "";
        // 获取父级DIV
        var fileIndex = $(this).parents(".file-preview-frame").attr("data-fileindex");
        var fileValue = $(this).parents(".col-sm-10").children("input").val();
        if (!isNaN(fileIndex)) {
            var title = $(this).parents(".file-preview-frame").attr("title");
            var id = $(this).parents(".file-preview-frame").attr("id");
            if (title == "" || title == null) {
                title = $("#" + id + " img").attr("title");
                for (var i = 0; i <= fileValue.split(",").length - 1; i++) {
                    var title1 = fileValue.split(",")[i].substring(fileValue.split(",")[i].lastIndexOf("/") + 1);
                    if (title1 == title) {
                        download = fileValue.split(",")[i];
                    }
                }
            } else {
                for (var i = 0; i <= fileValue.split(",").length - 1; i++) {
                    var title1 = fileValue.split(",")[i].substring(fileValue.split(",")[i].lastIndexOf("/") + 1);
                    if (title1 == title) {
                        download = fileValue.split(",")[i];
                    }
                }
            }
        } else {
            var number = fileIndex.match(/\d/);
            if (number) {
                download = fileValue.split(",")[number];
            }
        }
        var name = download.substring(download.lastIndexOf("/") + 1);
        if (download != "") {
            downloadFile(download, name);
        }
    })

    function downloadFile(url, name) {
        var a = document.createElement("a");
        a.download = name;
        a.href = url;
        $("body").append(a); // 修复firefox中无法触发click
        a.click();
        $(a).remove();
    }


</script>
</body>
</html>


